package com.jzo2o.market.controller.operation;

import com.jzo2o.common.model.PageResult;
import com.jzo2o.market.model.dto.request.ActivityQueryForPageReqDTO;
import com.jzo2o.market.model.dto.request.ActivitySaveReqDTO;
import com.jzo2o.market.model.dto.response.ActivityInfoResDTO;
import com.jzo2o.market.service.IActivityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description operationActivityContrpller
 * @Author liujiangyuan
 * @Date 2024-12-15-8:57
 */
@RestController("operationaAtivityController")
@RequestMapping("/operation/activity")
@Api(tags = "优惠券相关接口")
public class operationActivityContrpller {
    @Autowired
    private IActivityService iActivityService;

    @PostMapping("/save")
    @ApiOperation("保存优惠券活动")
    public void saveORupdateActivity( @RequestBody ActivitySaveReqDTO activitySaveReqDTO) {
        iActivityService.saveORupdateActivity(activitySaveReqDTO);
    }
    @GetMapping("/page")
    @ApiOperation("分页查询优惠券活动")
    public PageResult<ActivityInfoResDTO> pagequery(ActivityQueryForPageReqDTO activityQueryForPageReqDTO){
        return iActivityService.pagequery(activityQueryForPageReqDTO);
    }
    @GetMapping("/{id}")
    @ApiOperation("查询优惠券详情")
    public ActivityInfoResDTO queryById(@PathVariable Long id) {
        return iActivityService.selectById(id);
    }

    @PostMapping("/revoke/{id}")
    @ApiOperation("撤销活动")
    public void revoke(@PathVariable Long id) {
        iActivityService.revokeById(id);
    }
}
